﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _27_DDD.Models
{
    internal class BookConfig : IEntityTypeConfiguration<Books>
    {
        public void Configure(EntityTypeBuilder<Books> builder)
        {
            builder.ToTable("T_Books");
            builder.OwnsOne(e => e.title, nb =>
            {
                nb.Property(p => p.China).HasMaxLength(255);
                nb.Property(p => p.English).HasColumnType("varchar(255)");
            });
            builder.OwnsOne(e => e.body, nb =>
            {
                nb.Property(p => p.China);
                nb.Property(p => p.English).HasColumnType("varchar(Max)");
            });
        }
    }
}
